<form class="form-inline" method="get">

    <div class="form-group col-xs-3">
        {include file="public/areaSelector" province-name="pro" city-name="city" /}
    </div>
    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <input class="form-control" name="user_condition" value="{$user_condition}"
                   placeholder="会员手机|会员姓名|会员ID">
        </div>
    </div>
    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <input class="form-control" name="un_condition" value="{$un_condition}"
                   placeholder="联盟商名称|联盟商ID">
        </div>
    </div>
    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <input class="form-control" name="condition" value="{$condition}"
                   placeholder="活动主题">
        </div>
    </div>

    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <select id="status-selector" name="status" class="form-control" tabindex="-1">
                <option value="">无选择</option>
                <?php foreach($status_list as $itk=>$item){ ?>
                <option value="{$itk}" {if condition="$status!=''&&$status==$itk"}selected{/if}>{$item}</option>
                <?php } ?>
            </select>
        </div>
    </div>

    <br><br><br>

    <div class="form-group col-xs-4">
        <div class="col-xs-12">
            <span style="">活动期限(开始-结束)</span>{include file="public/dateRangePicker" picker-name="time_range" /}
        </div>
    </div>

    <div class="form-group col-xs-2">
        <button type="submit" class="btn btn-success">
            搜索
        </button>

        <button type="button" class="btn btn-primary" onclick="modal('{:url(\'add')}','添加活动')">
            添加活动
        </button>
    </div>
</form>

<hr>

<table class="table table-striped">
    <thead>
    <tr>
        <td>ID</td>
        <td>地区</td>
        <td>主办会员</td>
        <td>承办联盟商</td>
        <td>活动主题</td>
        <td>缩略图</td>
        <td>活动期限</td>
        <td>活动费用</td>
        <td>H链结算</td>
        <td>推荐</td>
        <td>显示</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    {volist name="list" id="item"}
    <tr>
        <td>{$item.id}</td>
        <td>
            <label class="label label-info">
                {:get_regionName($item['pro'])}-{:get_regionName($item['city'])}
            </label>
        </td>
        <td>
            {$item.umobile}【ID：{$item.uid}】
        </td>
        <td>
            {$item.untitle}【ID：{$item.union_id}】
        </td>
        <td>{$item.title}</td>
        <td>
            <a href="javascript:void(0);" onclick="ejectImg('{$item.thumb}','活动【{$item.title}】缩略图');">
                <img style="width:112px;height:96px;" src="{$item.thumb}">
            </a>
        </td>
        <td>
            <p>
                <label class="label label-warning">开始时间：{$item.begintime|date="Y-m-d H:i",###}</label>
            </p>
            <p>
                <label class="label label-warning">结束时间：{$item.endtime|date="Y-m-d H:i",###}</label>
            </p>
            <p>
                <label class="label label-warning">报名截止：{$item.signstop_time|date="Y-m-d H:i",###}</label>
            </p>
        </td>
        <td>
            <p>
                <label class="label label-warning">H币：{$item.coin}</label>
            </p>
            <p>
                <label class="label label-warning">现金：{$item.money}元</label>
            </p>
        </td>

        <td>
            {if condition="$item.status==0"}
            <label class="label label-danger">{$item.status|get_active_status}</label>
            {/if}
            {if condition="$item.status==1"}
            <label class="label label-success">{$item.status|get_active_status}</label>
            {/if}
        </td>

        <td>
            <?php
                    $is_recommend_1 = '推荐';
                    $is_recommend_0 = '不推荐';
                ?>
            {if $item["is_recommend"]}
            <label class="label label-success" data-toggle="ajaxSwitch" data-switch-status="1" data-reload="true"
                   data-switch-value-0="1|{$is_recommend_1}|label label-success|{:url('recommend',array('aid'=>$item['id'],'status'=>1))}"
                   data-switch-value-1="0|{$is_recommend_0}|label label-danger|{:url('recommend',array('aid'=>$item['id'],'status'=>0))}">{$is_recommend_1}</label>
            {else}
            <label class="label label-danger" data-toggle="ajaxSwitch" data-switch-status="0" data-reload="true"
                   data-switch-value-0="1|{$is_recommend_1}|label label-success|{:url('recommend',array('aid'=>$item['id'],'status'=>1))}"
                   data-switch-value-1="0|{$is_recommend_0}|label label-danger|{:url('recommend',array('aid'=>$item['id'],'status'=>0))}">{$is_recommend_0}</label>
            {/if}
        </td>
        <td>
            {if condition="$item.is_visible == 1"}
            显示
            {else/}
            隐藏
            {/if}
        </td>

        <td>
            <div class="btn-group">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    操作
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    {if condition="$item.status==0"}
                    <li>
                        <a href="javascript:void(0)" data-toggle="confirm"
                           data-title="H链结算"
                           data-content="确认结算？操作不可逆转,结算过程中请勿刷新或关闭本页面"
                           data-url="{:url('settleAccounts',array('id'=>$item['id']))}">
                            H链结算
                        </a>
                    </li>
                    {/if}
                    {if condition="$item.status==0"}
                    <li>
                        <a href="javascript:void(0)" onclick="modal('{:url(\'edit\',array(\'id\'=>$item[\'id\']))}', '编辑活动')">
                            编辑
                        </a>
                    </li>
                    {/if}
                    <li>
                        <a href="{:url('Order/index')}?ac_condition={$item.id}" >
                            订单
                        </a>
                    </li>
                    <li>
                        <a href="{:url('Comment/index')}?ac_condition={$item.id}" >
                            评论
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)" data-toggle="confirm"
                           data-title="删除活动"
                           data-content="活动将会被删除，确认删除？"
                           data-url="{:url('remove',array('id'=>$item['id']))}">
                            删除
                        </a>
                    </li>

                    <li role="separator" class="divider"></li>
                </ul>
            </div>
        </td>

    </tr>
    {/volist}
    </tbody>
</table>

<div class="row">
    <div class="col-xs-12" style="text-align: right;">
        {$list->render()}
    </div>
</div>

<script src="__PUBLIC__/vendors/select2/js/select2.min.js"></script>
<script type="application/javascript">
    $(function () {

        //获取分类
        $("#category-selector").select2({
            placeholder: "选择新闻分类",
            allowClear: true
        });

        $("#status-selector").select2({
            placeholder: "选择H链结算状态",
            allowClear: true
        });
    });
</script>